package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoTrainingShoppingPrSp;
import com.muyu.danmo.service.IDanmoTrainingShoppingPrSpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 培训班商品规格Controller
 * 
 * @author kunzong
 * @date 2024-11-29
 */
@RestController
@RequestMapping("/DanmoTrainingShoppingPrSp")
public class DanmoTrainingShoppingPrSpController extends BaseController
{
    @Autowired
    private IDanmoTrainingShoppingPrSpService danmoTrainingShoppingPrSpService;

    /**
     * 查询培训班商品规格列表
     */
//    @RequiresPermissions("system:DanmoTrainingShoppingPrSp:list")
    @GetMapping("/list")
    public Result list(DanmoTrainingShoppingPrSp danmoTrainingShoppingPrSp)
    {
        startPage();
        List<DanmoTrainingShoppingPrSp> list = danmoTrainingShoppingPrSpService.selectDanmoTrainingShoppingPrSpList(danmoTrainingShoppingPrSp);
        return getDataTable(list);
    }

    /**
     * 导出培训班商品规格列表
     */
//    @RequiresPermissions("system:DanmoTrainingShoppingPrSp:export")
    @Log(title = "培训班商品规格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoTrainingShoppingPrSp danmoTrainingShoppingPrSp)
    {
        List<DanmoTrainingShoppingPrSp> list = danmoTrainingShoppingPrSpService.selectDanmoTrainingShoppingPrSpList(danmoTrainingShoppingPrSp);
        ExcelUtil<DanmoTrainingShoppingPrSp> util = new ExcelUtil<DanmoTrainingShoppingPrSp>(DanmoTrainingShoppingPrSp.class);
        util.exportExcel(response, list, "培训班商品规格数据");
    }

    /**
     * 获取培训班商品规格详细信息
     */
//    @RequiresPermissions("system:DanmoTrainingShoppingPrSp:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoTrainingShoppingPrSpService.selectDanmoTrainingShoppingPrSpById(id));
    }

    /**
     * 新增培训班商品规格
     */
//    @RequiresPermissions("system:DanmoTrainingShoppingPrSp:add")
    @Log(title = "培训班商品规格", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoTrainingShoppingPrSp danmoTrainingShoppingPrSp)
    {
        return toAjax(danmoTrainingShoppingPrSpService.insertDanmoTrainingShoppingPrSp(danmoTrainingShoppingPrSp));
    }

    /**
     * 修改培训班商品规格
     */
//    @RequiresPermissions("system:DanmoTrainingShoppingPrSp:edit")
    @Log(title = "培训班商品规格", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoTrainingShoppingPrSp danmoTrainingShoppingPrSp)
    {
        return toAjax(danmoTrainingShoppingPrSpService.updateDanmoTrainingShoppingPrSp(danmoTrainingShoppingPrSp));
    }

    /**
     * 删除培训班商品规格
     */
//    @RequiresPermissions("system:DanmoTrainingShoppingPrSp:remove")
    @Log(title = "培训班商品规格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoTrainingShoppingPrSpService.deleteDanmoTrainingShoppingPrSpByIds(ids));
    }
}
